﻿



using System;
using System.Collections.Generic;
using System.Web;

using System.Data;
using System.Text;
using Maticsoft.Model;
using Utils;
using Maticsoft.DBUtility;
/// <summary>
///city 的摘要说明
/// </summary>
public partial class city : FBasePage
{
    // Fields

    protected DataTable cityletters = new DataTable();

    protected int i = 0;
    protected int letterscount = 0;

    // Methods
    protected List<Category> GetCitysByLetter(string let)
    {
        Maticsoft.BLL.Category category = new Maticsoft.BLL.Category();
        return category.GetModelList("letter='" + let + "' and zone='city'");
    }

    protected override void OnLoad(EventArgs e)
    {
        Maticsoft.BLL.Category category;
        base.OnLoad(e);
        string str = Helper.GetString(base.Request["ename"], string.Empty);
        if (str != string.Empty)
        {
            category = new Maticsoft.BLL.Category();
            List<Category> modelList = category.GetModelList("Zone='city' and ename='" + str + "'");
            if (modelList.Count > 0)
            {
                CookieHelper.SetCookie("cityid", modelList[0].Id.ToString(), DateTime.Now.AddYears(1));
                base.Response.Redirect("/index.aspx");
                base.Response.End();
                return;
            }
        }
        else if (base.Request.QueryString["Id"] != null)
        {
            category = new Maticsoft.BLL.Category();
            if (category.GetModelList("Zone='city'").Count > 0)
            {
                CookieHelper.SetCookie("cityid", "0", DateTime.Now.AddYears(1));
                base.Response.Redirect("/index.aspx");
                base.Response.End();
                return;
            }
        }
        this.cityletters = DbHelperSQL.SelectByFilter("*", string.Empty, " Sort_order desc,letter asc ", " (select distinct letter as letter,Sort_order,Id from category where zone='city') as t1");
        DataSet set = new Maticsoft.BLL.Category().GetList(" Zone='city' ");
        this.letterscount = set.Tables[0].Rows.Count;
    }
}

